package com.elitel.frame.base.service.strategy.service;

import com.elitel.frame.main.entity.enums.BuildServiceEnum;
import com.elitel.frame.main.entity.ext.PrjServiceExt;
import com.elitel.frame.main.entity.vo.ServiceConfig;
import org.springframework.data.redis.core.StringRedisTemplate;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

/**
 * 构建服务策略
 *
 * @author xqh
 * @date 2025/02/07
 */
public abstract class BuildServiceStrategy {


    /**
     * 获取策略
     *
     * @return 策略枚举
     */
    protected abstract BuildServiceEnum getTypeEnum();

    /**
     * 初始化策略类型
     */
    @PostConstruct
    private void init() {
        BuildServiceFactory.register(getTypeEnum().getType(), this);
    }


    /**
     * 构建服务模型
     *
     * @return 服务模型
     */
    public abstract List<ServiceConfig> buildServiceModel(List<PrjServiceExt> prjServiceExtList);


    public ServiceConfig getBaseServiceMap(PrjServiceExt service) {
        ServiceConfig serviceConfig = new ServiceConfig();
        serviceConfig.setServiceId(service.getGuid());
        serviceConfig.setServiceName(service.getServicename());
        serviceConfig.setServiceType(service.getServicetype());
        serviceConfig.setBusinessType(service.getServertype());
        serviceConfig.setStatus(service.getStatus());
        serviceConfig.setRemark(service.getRemark());
        return serviceConfig;
    }


}
